<?=
get_toolbar(array('accion' => 'custom',
    'botones' => '<a href="' . site_url(get_uri_string()) . '" class="btn btn-warning color-blanco">' . ulang('ver_listado_anuncios') . '</a>'));
?>
<?= get_alert(isset($success) ? $success : null, isset($error) ? $error : null); ?>
<div class="row">
    <div class="col-md-12">
        <div class="portlet box green" id="form_wizard_1">
            <div class="portlet-title">
                <div class="caption">
                    <i class="icon-reorder"></i> <?= ulang('nuevo_anuncio') ?> - <span class="step-title"><?= ulang('paso') ?> 2 <?= lang('de') ?> 4</span>
                </div>
            </div>
            <div class="portlet-body form">
                <form class="form-horizontal" action="<?= site_url($this->uri->uri_string()) ?>" id="form_mantenimiento" method="post">
                    <input type="hidden" name="pro_id" value="<?= isset($query) ? isset($query['pro_id']) ? $query['pro_id'] : ''  : '' ?>"/>
                    <div class="form-wizard">
                        <div class="form-body">
                            <?= $wizard ?>
                            <div id="bar" class="progress progress-striped" role="progressbar">
                                <div class="progress-bar progress-bar-success" style="width: 50%;"></div>
                            </div>
                            <div class="tab-pane active" id="tab1">
                                <div class="form-group">
                                    <label class="control-label col-md-4">* <?= ulang('pro_titulo') ?></label>
                                    <div class="col-md-5">
                                        <input type="text" value="<?= isset($query) ? isset($query['pro_titulo']) ? $query['pro_titulo'] : ''  : '' ?>" 
                                               name="pro_titulo" class="form-control" placeholder="<?= ulang('pro_titulo') ?>"/>
                                        <span class="help-block"><?= ulang('help_pro_titulo') ?></span>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-4">* <?= ulang('prd_desc') ?></label>
                                    <div class="col-md-5">
                                        <?php if (isset($query)){?>
                                            <?php if(count($query['d_descripciones']) > 1){?>
                                                <div class="row">
                                                    <div class="col-md-12">
                                                        <div class="portlet box green tabbable">
                                                            <div class="portlet-title">
                                                                <div class="caption">&nbsp;</div>
                                                            </div>
                                                            <div class="portlet-body">
                                                                <div class="tabbable portlet-tabs">
                                                                    <ul class="nav nav-tabs">
                                                                        <?php foreach ($query['d_descripciones'] as $desc) {
                                                                            echo '<li '.($desc['idi_id'] == 1 ? 'class="active"' : '').'><a href="#descripcion_tab_'.$desc['prd_id'].'" data-toggle="tab">'.ulang($desc['idi_slug']).'</a></li>';
                                                                        }?>
                                                                    </ul>
                                                                    <div class="tab-content">
                                                                        <?php foreach ($query['d_descripciones'] as $desc) {
                                                                            echo '<div class="tab-pane '.($desc['idi_id'] == 1 ? 'active' : '').'" id="descripcion_tab_'.$desc['prd_id'].'">';
                                                                            echo '<textarea class="form-control" placeholder="'.ulang('prd_desc').'" rows="3" name="prd_desc_'.$desc['idi_abrev'].'">'.$desc['prd_desc'].'</textarea>';
                                                                            echo "</div>";
                                                                        }?>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            <?php }else{?>
                                                <?php foreach ($query['d_descripciones'] as $desc) {?>
                                                    <textarea class="form-control" placeholder="<?= ulang('prd_desc') ?>" rows="3" name="prd_desc_<?=$desc['idi_abrev']?>"><?= $desc['prd_desc'] ?></textarea>
                                                <?php }?>
                                            <?php }?>
                                        <?php }else{?>
                                            <textarea class="form-control" placeholder="<?= ulang('prd_desc') ?>" rows="3" name="prd_desc_es"></textarea>
                                        <?php }?>
                                        <span class="help-block"><?= ulang('help_prd_desc') ?></span>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-4"><?= ulang('pro_precio') ?></label>
                                    <div class="col-md-5">
                                        <div class="input-group input-medium">
                                            <input type="text" value="<?= isset($query) ? isset($query['pro_precio']) ? $query['pro_precio'] : ''  : '' ?>" 
                                                   name="pro_precio" class="form-control" placeholder="<?= ulang('pro_precio') ?>"/>
                                            <span class="input-group-addon">
                                                <i class="icon-eur"></i>
                                            </span>
                                        </div>
                                        <span class="help-block"><?= ulang('help_pro_precio') ?></span>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-4"><?= ulang('pro_fec_nacimiento') ?></label>
                                    <div class="col-md-5">
                                        <input type="text" value="<?= isset($query) ? isset($query['pro_fec_nacimiento']) ? $this->fechas->fec_mysql_to_str($query['pro_fec_nacimiento']) : ''  : '' ?>" 
                                               name="pro_fec_nacimiento" data-date-format="dd/mm/yyyy" class="form-control input-medium date-picker" placeholder="<?= ulang('pro_fec_nacimiento') ?>"/>
                                        <span class="help-block"><?= ulang('help_pro_fec_nacimiento') ?></span>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-4"><?= $max_razas == 1 ? ulang('ppz_fk_prod_raza') : ulang('ppz_fk_prod_raza') . 's' ?></label>
                                    <div class="col-md-5">
                                        <select id="ppz_fk_prod_raza" class="form-control select2" multiple name="ppz_fk_prod_raza[]">
                                        <!--select class="form-control select2" multiple="" id="ppz_fk_prod_raza" name="ppz_fk_prod_raza[]" -->
                                            <?php foreach ($razas as $raza) {
                                                $razselected = '';
                                                if (isset($query)) {
                                                    foreach ($query['d_razas'] as $razas_seleccionadas) {
                                                        if ($razas_seleccionadas['prz_id'] == $raza['prz_id']) {
                                                            $razselected = 'selected';
                                                        }
                                                    }
                                                }
                                                ?>
                                                <option value="<?= $raza['prz_id'] ?>" <?= $razselected ?>>
                                                <?= lang($raza['prz_slug']) ?>
                                                </option>
                                            <?php } ?>
                                        </select>
                                        <span class="help-block"><?= $max_razas == 1 ? ulang('maximo_una_raza') : ulang('maximo_dos_razas') ?></span>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-4"><?= "¿" . ulang('pro_mestizo') . "?" ?></label>
                                    <div class="col-md-5">
                                        <div class="checkbox-list">
                                            <label class="checkbox-inline">
                                                <input type="checkbox" name="pro_mestizo" value="S">
                                            </label>
                                        </div>
                                        <span class="help-block"><?= ulang('help_emp_desc') ?></span>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-3"></label>
                                    <div class="col-md-8">
                                        <p class="form-control-static"><?= lang('help_machos_hembras') ?></p>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-4"><?= ulang('pro_machos') ?></label>
                                    <div class="col-md-2">
                                        <input type="text" value="<?= isset($query) ? isset($query['pro_machos']) ? $query['pro_machos'] : ''  : '' ?>" 
                                               name="pro_machos" class="form-control" placeholder="<?= ulang('pro_machos') ?>"/>
                                    </div>
                                    <label class="control-label col-md-1"><?= ulang('pro_hembras') ?></label>
                                    <div class="col-md-2">
                                        <input type="text" value="<?= isset($query) ? isset($query['pro_hembras']) ? $query['pro_hembras'] : ''  : '' ?>" 
                                               name="pro_hembras" class="form-control" placeholder="<?= ulang('pro_hembras') ?>"/>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <div class="col-md-4"></div>
                                    <div class="col-md-5">
                                        <button type="submit" id="boton_grabar" class="btn btn-info"><?= ulang('grabar_y_pasar_a_la_siguiente_pantalla') ?></button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    jQuery(function(){
        $('#ppz_fk_prod_raza').select2({
            placeholder: '<?=ulang('selecciona_una_raza')?>',
            allowClear: true,
            maximumSelectionSize: <?= $max_razas ?>
        });
        $('.date-picker').datepicker({
            autoclose: true,
            weekStart: 1,
            language: 'es'
        });
    })
</script>